<!-- 
@name: 评价列表
-->
<template>
	<div id="BankingBusinessList" class="page">
		<div class="content-wrap">
			<div class="diy-area">
				<div class="like">
					<div class="type2" v-if="listModel" ref='type2Scorll' id='type2Scorll'>
						<van-list v-model="loading" offset='0' :finished="finished" finished-text="没有更多了" @load="onLoad">
							<div class="flex-row item" v-for="(item,index) in likeList" :key="index">
								<img object-fit="fill" class="icon1" :src="item.memberPhoto?item.memberPhoto:require( '@/assets/images/no-pic.jpg')"></img>
								<div class="flex-column " style="flex:1">
									<div class="flex-between flex-alignCenter">
										<div class="name">{{item.memberName?item.memberName:'未知用户'}}</div>
										<div class="date">{{item.createdTime}}</div>
									</div>
									<div class="text3 flex-alignCenter">
										<van-rate readonly v-model="item.score" allow-half :icon="$store.state.rateIcon" :void-icon="$store.state.rateIcon2" />
										<span v-if="item.score == 5" style="margin-left:0.2rem">超赞</span>
									</div>
									<div class="content">
										{{item.content}}
									</div>
									<div class="imgWrap">
										<img v-for="(photoItem,photoIndex) in item.photo" :key="photoIndex" object-fit="fill" class="img" :src='photoItem'></img>
									</div>
									<div class="text4">
										已消费：{{item.goodsPaName}}{{item.price}}
									</div>
								</div>
							</div>
						</van-list>

					</div>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
export default {
	name: 'app',
	components: {},
	data() {
		return {
			searchValue: '',
			searchTypeIndex: '',
			getGtypeList: [],
			listModel: true, //true 列表模式 false 大图模式
			searchTypeList: [
				{ value: '销量最高', pkey: 'XS' },
				{ value: '距离最近', pkey: 'NEAR' },
				{ value: '评分最高', pkey: 'RATE' },
			],
			rateIcon:
				'https://filetest.xinanshizu.com/file/v2/image?file=4235.png&code=00D96F02428C3AD8E53A3A6724AEC38C',
			rateIcon2:
				'https://filetest.xinanshizu.com/file/v2/image?file=4236.png&code=C993979E415E6C8ED7784EFD6C0AEAFE',

			searchData: {
				sortType: 'XS', //XS 销量,NEAR 距离,RATE 评分
				page: 0,
				pagesize: 5,
				lng: '1',
				lat: '1',
			},
			likeList: [],
			activeName: '',
			loading: false,
			finished: false,
		};
	},

	created() {
		if (this.$route.query.pkey) {
			//跳转过来的分类pkey
			this.searchData.goodsPkey = Number(this.$route.query.pkey);
		}
		// this.getGtype_goods();
	},
	methods: {
		goDetail(item) {
			// console.log()
			this.$router.push({
				path: '/BankingBusiness/share',
				query: { item: JSON.stringify(item) },
			});
		},
		sortChange(pkey) {
			this.searchData.sortType = pkey;
			this.clearSearch();
			this.finished = true;
			this.getData(true);
		},
		onLoad() {
			console.log('触底');
			this.getData();
		},
		onClick() {
			this.clearSearch();
			this.finished = true;
			this.getData(true);
		},
		getGtype_goods() {
			this.$myApi.getGtype_goods().then((res) => {
				if (res.code == 0) {
					var arr = [{ name: '全部', pkey: '' }, ...res.result];
					this.getGtypeList = arr;
				} else {
				}
			});
		},
		getData(finished) {
			// finished 避免清空列表出发刷新
			var params = this.searchData;
			this.$myApi.queryAppAppraises_goods(params).then((res) => {
				if (res.code == 0) {
					this.likeList = [...this.likeList, ...res.result.content];
					this.loading = false;
					this.searchData.page++;
					if (finished) {
						this.finished = false;
					}
					if (res.result.content.length < 5) {
						this.finished = true;
					}
				} else {
				}
			});
		},
		clearSearch() {
			this.likeList = [];
			this.searchData.page = 0;
			this.searchData.pagesize = 5;
			this.finished = false;
		},
		onSearch(e) {
			console.log(e);
			this.clearSearch();
			this.searchData.title = e;
			this.finished = true;
			this.getData(true);
		},
		onCancel() {},
	},
};
</script>
<style lang="less" scoped>
#BankingBusinessList {
	padding-left: 0rem;
	padding-right: 0rem;
	min-height: 100vh;
	background-color: #fafafa;
	
	padding-bottom: 0;
	.content-wrap {
		width: 100%;
		height: auto;
		.diy-area {
			// background-color: #fff;
			position: relative;
			background-color: inherit;

			img {
				vertical-align: top;
			}

			.banner {
				.bannerImg {
					height: 4rem;
					width: 100%;
				}
			}
			.br {
				height: 0.2rem;
				width: 100%;
				background: #fafafa;
			}
			.likeTitle {
				font-size: 0.32rem;
				font-family: PingFang SC;
				font-weight: bold;
				color: #000000;
				margin-bottom: 0.24rem;
				text-align: center;
			}
			.like {
				margin: 0.25rem;
                background: #fff;
				height: calc(100vh - 46px - 0.5rem);
				position: relative;
				box-sizing: border-box;
				border-radius: 10px;

				.type2 {
					width: 100%;
					overflow-x: scroll;
					height: 100%;
					padding-bottom: 1rem;
					img {
						height: 1.1rem;
						width: 1.1rem;
						margin-right: 0.24rem;
						border-radius: 5px;
					}
					.item {
						padding: 0.3rem ;
						border-bottom: 1px solid #ededed;
						.icon1 {
							width: 0.72rem;
							height: 0.72rem;
							border-radius: 50%;
							margin-right: 0.18rem;
						}
						.name {
							font-size: 0.28rem;
							font-weight: bold;
							color: #333333;
                            margin-bottom: 0.2rem;
						}
						.date {
							font-size: 0.24rem;
							color: #999999;
                             margin-bottom: 0.2rem;
						}
						.text3 {
							font-size: 0.24rem;
							color: #D95954;
						}
						.icon2 {
							width: 0.24rem;
							height: 0.24rem;
						}
						.content {
							font-size: 0.28rem;
							color: #333333;
							line-height: 0.42rem;
							text-overflow: -o-ellipsis-lastline;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							line-clamp: 2;
							-webkit-box-orient: vertical;
						}
						.imgWrap {
							width: 100%;
							display: grid;
							grid-template-columns: repeat(3, 30%);
							grid-gap: 4%;
							.img {
								height: 1.8rem;
								width: 1.8rem;
							}
						}
						.text4 {
							background: rgba(255, 212, 49, 0.12);
							border-radius: 10px;
							font-size: 0.24rem;
							color: #D95954;
							margin-top: 0.16rem;
						}
					}
				}
			}
			.iconWrap {
				position: relative;
				padding-bottom: 0.55rem;
				border-radius: 20px 20px 0 0;
				top: -0.3rem;
				// margin-top: -0.4rem;
				background-color: #fafafa;
				z-index: 999;
				display: grid;
				grid-template-columns: repeat(4, 25%);
				.iconImg {
					width: 0.8rem;
					height: 0.8rem;
					margin-bottom: 0.12rem;
				}
				.item {
					-webkit-box-flex: 1;
					flex: 1;
					margin-top: 0.3rem;
					font-size: 0.24rem;
					text-align: center;
				}
			}
		}
	}
}
</style>
<style lang="less" scoped>
/deep/.van-search .van-cell {
	padding-top: 0.2rem;
	padding-bottom: 0.2rem;
	font-size: 0.28rem;
}
/deep/.van-tab {
	// flex: 0 1 auto;
	// width: 1rem;
	font-size: 0.3rem;
}
/deep/.van-tab--active {
	font-weight: bold;
	font-size: 0.32rem;
}
</style>